import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const routes = [
  {
    name: 'Login',
    path: '/Login',
    component: () => import('./view/Login'),
  },
  {
  name: 'main',
  path: '/',
  component: () => import('./view/main'),
  meta: {
    title: '首页'
  },
  children: [{
    name: 'CategorayEdit',
    path: '/CategorayEdit',
    component: () => import('./view/CategorayEdit'),
  },
  {
    name: 'CategorayList',
    path: '/CategorayList',
    component: () => import('./view/CategorayList'),
  },
  {
    name: 'CategorayEdit',
    path: '/CategorayEdit/:id',
    component: () => import('./view/CategorayEdit'),
    props: true
  },
  {
    name: 'itemList',
    path: '/itemList',
    component: () => import('./view/itemList'),
  },
  {
    name: 'itemEdit',
    path: '/itemEdit',
    component: () => import('./view/itemEdit'),
    props: true
  },
  {
    name: 'itemEdit',
    path: '/itemEdit/:id',
    component: () => import('./view/itemEdit'),
    props: true
  },
  {
    name: 'heroList',
    path: '/heroList',
    component: () => import('./view/heroList'),
  },
  {
    name: 'heroEdit',
    path: '/heroEdit',
    component: () => import('./view/heroEdit'),
    props: true
  },
  {
    name: 'heroEdit',
    path: '/heroEdit/:id',
    component: () => import('./view/heroEdit'),
    props: true
  },
  {
    name: 'ArticleEdit',
    path: '/ArticleEdit',
    component: () => import('./view/ArticleEdit'),
  },
  {
    name: 'ArticleList',
    path: '/ArticleList',
    component: () => import('./view/ArticleList'),
  },
  {
    name: 'ArticleEdit',
    path: '/ArticleEdit/:id',
    component: () => import('./view/ArticleEdit'),
    props: true
  },
  {
    name: 'AdsEdit',
    path: '/AdsEdit',
    component: () => import('./view/AdsEdit'),
  },
  {
    name: 'AdsList',
    path: '/AdsList',
    component: () => import('./view/AdsList'),
  },
  {
    name: 'AdsEdit',
    path: '/AdsEdit/:id',
    component: () => import('./view/AdsEdit'),
    props: true
  },
  {
    name: 'AdminEdit',
    path: '/AdminEdit',
    component: () => import('./view/AdminEdit'),
  },
  {
    name: 'AdminList',
    path: '/AdminList',
    component: () => import('./view/AdminList'),
  },
  {
    name: 'AdminEdit',
    path: '/AdminEdit/:id',
    component: () => import('./view/AdminEdit'),
    props: true
  },]
}]

const router = new Router({
  mode: 'hash',
  routes
})

router.beforeEach((to, from, next) => {
  const title = to.meta && to.meta.title;
  if (title) {
    document.title = title;
  }
  next();
});

export default router